<?php
/**
 * Created by PhpStorm.
 * User: zsl
 * Date: 2019-09-08
 * Time: 23:26
 */

namespace App\Controller;


use App\Service\SendEmailService;
use Symfony\Component\Routing\Annotation\Route;

/**
 * Class SendEmailController
 * @package App\Controller
 * @Route("/sendEmail/")
 */
class SendEmailController
{
    /**
     * @var SendEmailService
     */
    private $sendEmailService;

    /**
     * SendEmailController constructor.
     *
     * @param SendEmailService $sendEmailService
     */
    public function __construct(SendEmailService $sendEmailService)
    {
        $this->sendEmailService = $sendEmailService;
    }

    /**
     * @param $query
     *
     * @return string
     * @Route("send")
     */
    public function send($query)
    {
        $body    = $query['body'] ?? 'default body';
        $subject = $query['subject'] ?? 'default subject';
        $result  = $this->sendEmailService->send($subject, $body);
        return $result;
    }
}